<?php require 'common/header.php';?>
<?php require 'common/left.php';?>
<div id="main-content">
  <h2>欢迎您 <?php echo $_COOKIE['adminname'];?></h2>
  <p id="page-intro">兑换管理。</p>
  <div class="clear"></div>
  <div class="content-box">
    <div class="content-box-header">
      <h3>兑换管理</h3>
      <div class="clear"></div>
    </div>
    <div class="content-box-content">
      <div class="tab-content default-tab" id="tab1" style="display: block;">
        <div class="form">
          <form id="js-form" method="post" action="<?php echo Qtpl::createUrl('order', 'index','','admin');?>">
            <fieldset class="clearfix">
                <p><span><select name="s">
                	<option value="0">全部</option>
                    <option value="1">未处理</option>
                    <option value="2">已确认</option>
                    <option value="3">已取消</option>
                </select>
                </span>
                <input type="submit" name="" id="button" class="button" value="筛选">
				</p>
            </fieldset>
          </form>
        </div>
        <hr>
        <table>
          <thead>
            <tr>
              <th>编号</th>
              <th>礼物名称</th>
              <th>姓名</th>
              <th>电话</th>
              <th>地址</th>
              <th>状态/时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tfoot>
            <tr>
              <td colspan="5"><?php echo Qtpl::paged($_tpl['pageSize'],core_lib_constant::PAGE_NUM,$_tpl['page'],'order','index','style','admin');?></td>
            </tr>
          </tfoot>
          <tbody>
          <?php 
          if($_tpl['order']){
          	foreach ($_tpl['order'] as $k=>$v) {
          		$altrow = $k/2 == 0 ? 'alt-row' : '';
          ?>
           <tr class="<?php echo $altrow;?>">
            <td><?php echo Qutil::enId($v['oid']);?></td>
            <td><?php echo $v['gift_name'];?></td>
            <td><?php echo $v['realname'];?></td>
            <td><?php echo $v['phone'];?></td>
            <td><?php echo $v['address'].'/zip:'.intval($v['zip']);?></td>
            <td><?php echo $v['is_send'] == 1 ? "已发货/".date('Y-m-d',$v['send_time']) : ($v['cancel'] == 1 ? "已取消/".date('Y-m-d',$v['cancel_time']) : "未处理/".date('Y-m-d',$v['create_time']));?></td>
            <td><?php if($v['is_send'] == 0 && $v['cancel'] == 0){?><a onclick="return confirm('你确定要发货吗？')" href="<?php echo Qtpl::createUrl('order', 'send',array('oid'=>$v['oid'],'token'=>$_tpl['token']),'admin');?>">发货</a> <a onclick="return confirm('你确定要取消吗？')" href="<?php echo Qtpl::createUrl('order', 'cancel',array('oid'=>$v['oid'],'token'=>$_tpl['token']),'admin');?>">取消</a><?php }else{echo '无';}?></td>
          <?php
          		}
          	}else{
          		echo '<td colspan="8">暂无内容</td>';
          	}
          ?>
          </tr>
         </tbody>
        </table>
      </div>
    </div>
  </div>
<?php require 'common/footer.php';?>